<!DOCTYPE html>
<html lang="zh_CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box1{
            border: purple 10px solid;
        }
        .box2{
            width: 200px;
            height: 200px;
            background-color: #bfa;
            float: left;
        }
/*使用伪类解决高度塌陷*/
        .box1::after{
/*表示在box1盒子中的最后面添加内容*/
/*添加内容*/
            content: '1';
/*默认情况下用after伪类添加的内容为行内元素*/
            display: block;
            clear: both;
        }
    </style>
</head>
<body>
    <div class="box1">
        <div class="box2"></div>

    </div>
</body>
</html>